home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 July / CD 3 / redhat-6.2.iso / RedHat / instimage / usr / lib / anaconda / iw / installpath.py < prev    next >
Encoding:
Python Source  |  2000-03-08  |  7.9 KB  |  256 lines

  1. from gtk import *
  2. from iw import *
  3. from language import *
  4. from welcome import *
  5. from progress import *
  6. from package import *
  7. from network import *
  8. from account import *
  9. from auth import *
  10. from mouse import *
  11. from keyboard import *
  12. from format import *
  13. from congrats import *
  14. from dependencies import *
  15. from lilo import *
  16. from silo import *
  17. from examine import *
  18. from bootdisk import *
  19. from timezone import *
  20. from xconfig import *
  21. from fdisk import *
  22. from rootpartition import *
  23. from confirm import *
  24. import iutil
  25. from translate import _
  26. import installclass
  27.  
  28. UPGRADE = 0
  29. INSTALL = 1
  30.  
  31. CUSTOM = 2
  32. WORKSTATION_GNOME = 3
  33. WORKSTATION_KDE = 4
  34. SERVER = 5
  35.  
  36. class InstallPathWindow (InstallWindow):        
  37.  
  38.     installTypes = ((WORKSTATION_GNOME, _("GNOME Workstation"),
  39.                      "gnome-workstation.png"),
  40.                     (WORKSTATION_KDE, _("KDE Workstation"),
  41.                      "kde-workstation.png"),
  42.                     (SERVER, _("Server"), "server.png"),
  43.                     (CUSTOM, _("Custom"), "custom.png"))
  44.  
  45.     def __init__ (self, ics):
  46.     if iutil.getArch() == 'sparc':
  47.         BootloaderWindow = SiloWindow
  48.             BootloaderSkipname = "silo"
  49.     else:
  50.         BootloaderWindow = LiloWindow
  51.             BootloaderSkipname = "lilo"            
  52.  
  53.     self.installSteps = [
  54.                      FDiskWindow,
  55.              ( AutoPartitionWindow, "partition" ),
  56.              ( PartitionWindow, "partition" ),
  57.              ( FormatWindow, "format" ),
  58.              ( BootloaderWindow, BootloaderSkipname ),
  59.              ( NetworkWindow, "network" ),
  60.              ( TimezoneWindow, "timezone" ),
  61.              ( AccountWindow, "accounts" ),
  62.              ( AuthWindow, "authentication" ),
  63.              ( PackageSelectionWindow, "package-selection" ), 
  64.              ( UnresolvedDependenciesWindow, "dependencies" ),
  65.                      ( MonitorWindow, "monitor" ),
  66.                      ( XConfigWindow, "xconfig" ),
  67.                      ( ConfirmWindow, "confirm" ),
  68.              InstallProgressWindow,
  69.              ( BootdiskWindow, "bootdisk" ),
  70.              ( CongratulationWindow, "complete" )
  71.            ]
  72.  
  73.     self.upgradeSteps = [
  74.              ( UpgradeExamineWindow, "custom-upgrade"),
  75.              ( BootloaderWindow, BootloaderSkipname ),
  76.              UnresolvedDependenciesWindow,
  77.              InstallProgressWindow,
  78.              ( BootdiskWindow, "bootdisk" ),
  79.              CongratulationWindow
  80.            ]
  81.  
  82.     InstallWindow.__init__ (self, ics)
  83.  
  84.         ics.readHTML ("instpath")
  85.  
  86.     self.commonSteps = [ ( LanguageWindow, "language" ), 
  87.                  ( KeyboardWindow, "keyboard" ),
  88.                  ( MouseWindow, "mouse" ),
  89.                  ( WelcomeWindow, "welcome" ),
  90.                  ( InstallPathWindow, "installtype" ),
  91.                ]
  92.  
  93.         ics.setTitle (_("Install Type"))
  94.         ics.setNextEnabled (1)
  95.         self.ics = ics
  96.  
  97.     def getNext(self):
  98.     from fstab import GuiFstab
  99.  
  100.     if not self.__dict__.has_key("upgradeButton"):
  101.         return
  102.  
  103.     # Hack to let backing out of upgrades work properly
  104.     if self.todo.fstab:
  105.         self.todo.fstab.turnOffSwap()
  106.  
  107.     needNewDruid = 0
  108.     icw = self.ics.getICW ()
  109.     if self.upgradeButton.get_active():
  110.         self.todo.upgrade = 1
  111.             icw.setStateList (self.commonSteps + 
  112.                               self.upgradeSteps, len (self.commonSteps)-1)
  113.     else:
  114.             icw.setStateList (self.commonSteps + 
  115.                               self.installSteps, len (self.commonSteps)-1)
  116.         self.todo.upgrade = 0
  117.  
  118.         for (button, type) in self.installClasses:
  119.         if button.get_active():
  120.             break
  121.  
  122.         if type == WORKSTATION_GNOME and self.orig != WORKSTATION_GNOME:
  123.         self.todo.setClass (installclass.GNOMEWorkstation (self.todo.expert))
  124.         needNewDruid = 1
  125.         elif type == WORKSTATION_KDE and self.orig != WORKSTATION_KDE:
  126.         self.todo.setClass (installclass.KDEWorkstation (self.todo.expert))
  127.         needNewDruid = 1
  128.         elif type == SERVER and self.orig != SERVER:
  129.         self.todo.setClass (installclass.Server (self.todo.expert))
  130.         needNewDruid = 1
  131.         elif type == CUSTOM and self.orig != CUSTOM:
  132.         self.todo.setClass (installclass.CustomInstall (self.todo.expert))
  133.         needNewDruid = 1
  134.  
  135.     # This makes the error message delivery come at a sane place
  136.     if needNewDruid or not self.todo.fstab:
  137.         self.todo.fstab = GuiFstab(self.todo.setupFilesystems, 
  138.                        self.todo.serial, 0, 0,
  139.                        self.todo.intf.waitWindow,
  140.                        self.todo.intf.messageWindow)
  141.  
  142.         # set state of disk druid to be read-only if needed
  143.         if (InstallPathWindow.fdisk.get_active()):
  144.             self.todo.fstab.setReadonly(1)
  145.         else:
  146.             self.todo.fstab.setReadonly(0)
  147.  
  148.     self.todo.fstab.setRunDruid(InstallPathWindow.fdisk.get_active())
  149.  
  150.     def toggled (self, widget, type):
  151.         if not widget.get_active (): return
  152.         if type == INSTALL:
  153.         self.installBox.set_sensitive(1)
  154.         elif type == UPGRADE:
  155.         self.installBox.set_sensitive(0)
  156.  
  157.     def pixRadioButton (self, group, label, pixmap):
  158.         im = self.ics.readPixmap (pixmap)
  159.         if im:
  160.             im.render ()
  161.             pix = im.make_pixmap ()
  162.             hbox = GtkHBox (FALSE, 5)
  163.             hbox.pack_start (pix, FALSE, FALSE, 0)
  164.             label = GtkLabel (label)
  165.             label.set_alignment (0.0, 0.5)
  166.             hbox.pack_start (label, TRUE, TRUE, 15)
  167.             button = GtkRadioButton (group)
  168.             button.add (hbox)
  169.         else:
  170.             button = GtkRadioButton (group, label)
  171.         return button
  172.  
  173.     def getScreen (self):
  174.     if (self.todo.instClass.installType == "install"):
  175.             self.ics.getICW ().setStateList (self.commonSteps + 
  176.                 self.installSteps, len (self.commonSteps)-1)
  177.             self.todo.upgrade = 0
  178.         return None
  179.     elif (self.todo.instClass.installType == "upgrade"):
  180.             self.ics.getICW ().setStateList (self.commonSteps + 
  181.                 self.upgradeSteps, len (self.commonSteps)-1)
  182.             self.todo.upgrade = 1
  183.         return None
  184.  
  185.     box = GtkVBox (FALSE, 5)
  186.  
  187.     installButton = self.pixRadioButton (None, _("Install"), "install.png")
  188.         installButton.connect ("toggled", self.toggled, INSTALL)
  189.     self.upgradeButton = self.pixRadioButton (installButton, _("Upgrade"), "upgrade.png")
  190.         self.upgradeButton.connect ("toggled", self.toggled, UPGRADE)
  191.  
  192.     if (self.todo.upgrade):
  193.         self.upgradeButton.set_active(1)
  194.             self.toggled (self.upgradeButton, UPGRADE)
  195.         self.orig = None
  196.         default = None
  197.     else:
  198.         instClass = self.todo.getClass()
  199.         self.orig = None
  200.         installButton.set_active(1)
  201.         if isinstance(instClass, installclass.GNOMEWorkstation):
  202.         self.orig = WORKSTATION_GNOME
  203.         elif isinstance(instClass, installclass.KDEWorkstation):
  204.         self.orig = WORKSTATION_KDE
  205.         elif isinstance(instClass, installclass.Server):
  206.         self.orig = SERVER
  207.         elif isinstance(instClass, installclass.CustomInstall):
  208.         self.orig = CUSTOM
  209.  
  210.         if (self.orig):
  211.         default = self.orig
  212.         else:
  213.         default = WORKSTATION_GNOME
  214.  
  215.         self.installBox = GtkVBox (FALSE, 0)
  216.         group = None
  217.     self.installClasses = []
  218.     for (type, name, pixmap) in self.installTypes:
  219.             group = self.pixRadioButton (group, name, pixmap)
  220.             self.installBox.pack_start (group, FALSE)
  221.         self.installClasses.append ((group, type))
  222.         if (type == default):
  223.         group.set_active (1)
  224.  
  225.     spacer = GtkLabel("")
  226.     spacer.set_usize(60, 1)
  227.  
  228.     table = GtkTable(2, 3)
  229.         table.attach(installButton, 0, 2, 0, 1)
  230.         table.attach(spacer, 0, 1, 1, 2, xoptions = FALSE)
  231.         table.attach(self.installBox, 1, 2, 1, 2, xoptions = FILL | EXPAND)
  232.         table.attach(self.upgradeButton, 0, 2, 2, 3)
  233.  
  234.     box.pack_start(table, FALSE)
  235.  
  236.     hbox = GtkHBox (FALSE)
  237.     if not InstallPathWindow.__dict__.has_key("fdisk"):
  238.         fdiskState = 0
  239.     else:
  240.         fdiskState = InstallPathWindow.fdisk.get_active()
  241.  
  242.     InstallPathWindow.fdisk = GtkCheckButton (_("Use fdisk"))
  243.     InstallPathWindow.fdisk.set_active(fdiskState)
  244.  
  245.     align = GtkAlignment ()
  246.     align.add (InstallPathWindow.fdisk)
  247.     align.set (0.0, 0.0, 0.0, 0.0)
  248.     hbox.pack_start (box, TRUE)
  249.     hbox.pack_start (align, FALSE)
  250.     box = hbox
  251.  
  252.         self.toggled (installButton, INSTALL)
  253.         self.toggled (self.upgradeButton, UPGRADE)
  254.         box.set_border_width (5)
  255.         return box
  256.